<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"  
                xmlns:h="http://java.sun.com/jsf/html"  
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../templates/StaffTemplate.xhtml">


    <ui:define name="nav_menu">
        <p:menubar model="#{staffEditAccountManagedBean.staffMenuModel}"/>
    </ui:define>

    <ui:define name="content">
        <f:view beforePhase="#{staffEditAccountManagedBean.initView}" >
            <h:form>
                <p:panel id="staffAccountDetail" header="#{bundle['staff.header.panel']}"  >
                    <p:messages id="statusMessages" />

                    <p:tabView id="tabViewStaffView" dynamic="false">

                        <p:tab id="tabStaffAccountInfo" title="#{bundle['staff.accountinfo.tab']}">
                            <h:panelGrid columns="3" cellpadding="5">
                                <h:outputLabel id="staffAccountUsernameLabel" value="#{bundle['staff.username.label']}" style="font-weight: bold"/>
                                <h:outputLabel id="username" value="#{staffEditAccountManagedBean.username}" />
                                <p:message for="username" />

                                <h:outputLabel id="staffAccountCurrentPasswordLabel" value="#{bundle['staff.currentpassword.label']}" style="font-weight: bold"/>
                                <p:password id="currpassword" value="#{staffEditAccountManagedBean.currentPassword}" feedback="false" minLength="1" /> 
                                <p:message for="currpassword" />

                                <h:outputLabel id="staffAccountNewPasswordLabel" value="#{bundle['staff.newpassword.label']}" style="font-weight: bold"/>
                                <p:password id="newpassword" value="#{staffEditAccountManagedBean.newPassword}" binding="#{pw}" feedback="true" minLength="6"> 
                                </p:password>
                                <p:message for="newpassword" />

                                <h:outputLabel id="staffAccountConfirmPasswordLabel" value="#{bundle['staff.confirmpassword.label']}" style="font-weight: bold" />
                                <p:password id="confirmpassword" value="#{staffEditAccountManagedBean.confirmPassword}" feedback="true" minLength="6" >
                                    <f:validator validatorId="matchPassword" />
                                    <f:attribute name="pw" value="#{pw}" />
                                </p:password>
                                <p:message for="confirmpassword" />

                                <h:outputLabel id="staffAccountLanguageLabel" value ="#{bundle['staff.languagepreferred.label']}" style="font-weight: bold"/>
                                <h:selectOneMenu id="language" value="#{staffEditAccountManagedBean.language}" required="true" requiredMessage="#{bundle['staff.languagepreferred.required']}">
                                    <f:selectItems value="#{enumLanguage.listItems}"/>
                                </h:selectOneMenu>
                                <p:message for="language"/>

                                <h:outputLabel id="staffAccountEmailLabel" value ="#{bundle['staff.email.label']}" style="font-weight: bold"/>
                                <h:outputText id="email" value="#{staffEditAccountManagedBean.email}" />
                                <p:message for="email"/>
                            </h:panelGrid>
                        </p:tab>

                        <p:tab id="tabStaffCorporateInfo" title="#{bundle['staff.corporateinfo.tab']}">
                            <h:panelGrid columns="3" cellpadding="5">

                                <h:outputLabel id="staffAccountDeptLabel" value ="#{bundle['staff.department.label']}" style="font-weight: bold"/>
                                <h:outputText id="dept" value="#{staffViewAccountManagedBean.department}" />
                                <p:message for="dept"/>

                                <h:outputLabel id="staffAccountJobPositionLabel" value ="#{bundle['staff.jobposition.label']}" style="font-weight: bold"/>
                                <h:outputText id="jobposition" value="#{staffViewAccountManagedBean.jobPosition}" />
                                <p:message for="jobposition"/>

                                <h:outputLabel id="staffAccountJoinDateLabel" value ="#{bundle['staff.joindate.label']}" style="font-weight: bold" />
                                <h:outputText id="joindate" value="#{staffViewAccountManagedBean.joinDate}" />
                                <p:message for="joindate"/>

                                <h:outputLabel id="staffAccountAccessLabel" value ="#{bundle['staff.accessrights.label']}" style="font-weight: bold" />
                                <p:dataList id="accessRights" value="#{staffViewAccountManagedBean.accessRightsList}" var="accessRight" itemType="square" >             
                                    <p:column>
                                        <h:outputText value="#{accessRight}" />
                                    </p:column>
                                </p:dataList>
                                <p:message for="accessRights"/>

                            </h:panelGrid>
                        </p:tab>

                        <p:tab id="tabStaffPersonalInfo" title="#{bundle['staff.personalinfo.tab']}">
                            <h:panelGrid  columns="3" cellpadding="5">
                                <h:outputLabel id="staffAccountNameLabel" value="#{bundle['staff.name.label']}" style="font-weight: bold"/>
                                <h:outputLabel id="name" value="#{staffEditAccountManagedBean.name}" />
                                <p:message for="username" />

                                <h:outputLabel id="staffAccountGenderLabel" value="#{bundle['staff.gender.label']}" style="font-weight: bold"/>
                                <h:outputLabel id="gender" value="#{staffEditAccountManagedBean.gender}" />
                                <p:message for="gender"/>

                                <h:outputLabel id="staffAccountBirthdateLabel" value ="#{bundle['staff.birthdate.label']}" style="font-weight: bold"/>
                                <h:outputText id="birthdate" value="#{staffEditAccountManagedBean.birthdate}" />
                                <p:message for="birthdate"/>

                                <h:outputLabel id="staffAccountCountryLabel" value ="#{bundle['staff.country.label']}" style="font-weight: bold"/>
                                <h:selectOneMenu id="country" value="#{staffEditAccountManagedBean.country}" required="true" requiredMessage="#{bundle['staff.country.required']}" >
                                    <f:selectItems value="#{enumCountry.listItems}"/>
                                </h:selectOneMenu>
                                <p:message for="country"/>

                                <h:outputLabel id="staffAccountEmailSecondaryLabel" value ="#{bundle['staff.emailSecondary.label']}" style="font-weight: bold"/>
                                <p:inputText id="emailSecondary" value="#{staffRegisterManagedBean.emailSecondary}" validatorMessage="#{bundle['staffAccount.username.validatorEmailFormat']}">
                                    <f:validator validatorId="checkValidEmail" />
                                </p:inputText>
                                <p:message for="emailSecondary"/>
                            </h:panelGrid>
                        </p:tab>

                    </p:tabView>

                    <p:ajaxStatus style="width:16px;height:16px;">
                        <f:facet name="start">
                            <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif"/>
                        </f:facet>
                        <f:facet name="complete">
                            <h:outputText value="" />
                        </f:facet>
                    </p:ajaxStatus>
                    <p:commandButton id="myFoodsageUpdateButton" value="#{bundle['staff.update.button']}" update="staffAccountDetail" actionListener="#{staffEditAccountManagedBean.updateStaffDetails}" ajax="false" />
                </p:panel>
            </h:form>
        </f:view>
    </ui:define>  
</ui:composition>
